﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ChinaSoft.Web.Model_tb_MidSoft_Users
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtUserAccount.Text.Trim().Length==0)
			{
				strErr+="用户帐号不能为空！\\n";	
			}
			if(this.txtUserPassword.Text.Trim().Length==0)
			{
				strErr+="用户密码不能为空！\\n";	
			}
			if(this.txtUserName.Text.Trim().Length==0)
			{
				strErr+="用户名不能为空！\\n";	
			}
			if(this.txtUserImgFolder.Text.Trim().Length==0)
			{
				strErr+="用户照片路径（当前年月2012不能为空！\\n";	
			}
			if(this.txtUserImgPath.Text.Trim().Length==0)
			{
				strErr+="用户照片名不能为空！\\n";	
			}
			if(this.txtCompany.Text.Trim().Length==0)
			{
				strErr+="单位名不能为空！\\n";	
			}
			if(this.txtDepartMent.Text.Trim().Length==0)
			{
				strErr+="部门不能为空！\\n";	
			}
			if(this.txtSex.Text.Trim().Length==0)
			{
				strErr+="性别不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtBirthDay.Text))
			{
				strErr+="出生日期格式错误！\\n";	
			}
			if(this.txtTel.Text.Trim().Length==0)
			{
				strErr+="联系电话不能为空！\\n";	
			}
			if(this.txtDuty.Text.Trim().Length==0)
			{
				strErr+="Duty不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreateTime.Text))
			{
				strErr+="创建时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCreateUserId.Text))
			{
				strErr+="创建人ID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtState.Text))
			{
				strErr+="用户状态(默认为1格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string UserAccount=this.txtUserAccount.Text;
			string UserPassword=this.txtUserPassword.Text;
			string UserName=this.txtUserName.Text;
			string UserImgFolder=this.txtUserImgFolder.Text;
			string UserImgPath=this.txtUserImgPath.Text;
			string Company=this.txtCompany.Text;
			string DepartMent=this.txtDepartMent.Text;
			string Sex=this.txtSex.Text;
			DateTime BirthDay=DateTime.Parse(this.txtBirthDay.Text);
			string Tel=this.txtTel.Text;
			string Duty=this.txtDuty.Text;
			DateTime CreateTime=DateTime.Parse(this.txtCreateTime.Text);
			int CreateUserId=int.Parse(this.txtCreateUserId.Text);
			int State=int.Parse(this.txtState.Text);

			ChinaSoft.Model.Model_tb_MidSoft_Users model=new ChinaSoft.Model.Model_tb_MidSoft_Users();
			model.UserAccount=UserAccount;
			model.UserPassword=UserPassword;
			model.UserName=UserName;
			model.UserImgFolder=UserImgFolder;
			model.UserImgPath=UserImgPath;
			model.Company=Company;
			model.DepartMent=DepartMent;
			model.Sex=Sex;
			model.BirthDay=BirthDay;
			model.Tel=Tel;
			model.Duty=Duty;
			model.CreateTime=CreateTime;
			model.CreateUserId=CreateUserId;
			model.State=State;

			ChinaSoft.BLL.BLL_tb_MidSoft_Users bll=new ChinaSoft.BLL.BLL_tb_MidSoft_Users();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
